# Export Recycle Bin to Excel Job
Dumps the contents of one or more site collections' recycle bins to an Excel file, optionally uploading the result to a SharePoint document library.
Configuration class: ExportRecycleBinToExcelCfg (SharepointCfg.ExportRecycleBinToExcelCfg)
Schedule: Monthly, on configured days of the month, at a random time between 00:00 and 06:00.
Supported on: SharePoint Online only.
# Purpose
Provides a point-in-time export of recycle bin contents (SharePoint Online only) for review or retention purposes, since the recycle bin itself is not easily searchable or reportable on on its own.
# Configuration
# RunEveryMonthOnDays
- Type:
int (list) - Default: —
- Description: Days of the month to run the job (e.g.
[1, 15]runs on the 1st and 15th). The job does not run at all if this is empty.
# SiteCollectionUrls
- Type:
string (list) - Default: —
- Description: Site collection URLs (relative to
SharepointUrl/SharepointRootServerRelativeUrl) whose recycle bins are exported. The job does not run at all if this is empty. Example:["/sites/ClientA", "/sites/ClientB"].
# UploadSingleExcelFileName
- Type:
string - Default: —
- Description: When set, all site collections are combined into a single Excel file with this name, sorted by site collection, then folder, then filename. When left empty, one Excel file is generated per site collection (named after its relative URL), sorted by deletion date (most recent first). Example:
"RecycleBinReport".
# UploadUrl
- Type:
string - Default: —
- Description: Document library URL (relative to the site) to upload the generated Excel file(s) to. When left empty, the file is written to a local temp folder and not deleted afterward. When set, the local file is deleted after a successful upload. Example:
"/sites/Reports/Shared Documents".
# How It Works
- For each URL in
SiteCollectionUrls, reads all items from that site collection's recycle bin (paged, 500 items per page). - Builds one row per recycle bin item with columns:
Id,SiteCollection,ItemType,ItemState,Directory,FileName,AuthorName,AuthorEmail,DeletedByName,DeletedByEmail,DeletedDate. - Depending on
UploadSingleExcelFileName, writes either one combined Excel file for all site collections, or one file per site collection. - If
UploadUrlis configured, uploads the generated file(s) to that document library and deletes the local temp copy.
If a run is still in progress when the schedule fires again the same day, the second run is skipped.
# Related
- Jobs — other background jobs